﻿CREATE PROCEDURE [dbo].[automovel_selectBYId]
		@automovelID int
AS
SET NOCOUNT ON
SELECT 
		TBAutomovel.automovelID,
		TBAutomovel.Descricao,
		TBAutomovel.ativo,
		TBAutomovel.modeloID,
		TBAutomovel.garagemID,
		TBAutomovel.anoFabricacao,
		TBAutomovel.anoModelo,
		TBAutomovel.preco,
		TBAutomovel.blindado,
		TBAutomovel.quilometragem,
		TBAutomovel.cambio,
		TBAutomovel.portas,
		TBAutomovel.cor,
		TBAutomovel.combustivel,
		TBAutomovel.observacoes,
		TBAutomovel.pasta,
		TBModelo.descricao as descricaoModelo,
		TBGaragem.nome as descricaoGaragem,
		TBMarca.descricao as descricaoMarca,
		TBMarca.marcaID as marcaID,
		TBAutomovel.Venda as Venda,
		TBAutomovel.vitrine as Vitrine
FROM
		TBAutomovel
INNER JOIN
		TBModelo ON(TBAutomovel.modeloID = TBModelo.modeloID)
INNER JOIN
		TBMarca ON(TBModelo.marcaID = TBMarca.marcaID)
INNER JOIN
		TBGaragem ON(TBAutomovel.garagemID = TBGaragem.garagemID)

WHERE
		TBAutomovel.automovelID = @automovelID

ORDER BY
			TBModelo.descricao
